package main.java.iterator;

/**
 * 迭代器模式
 */
public class Demo {
    public static void main(String[] args) {
        Student student1 = new Student("张三", "001");
        Student student2 = new Student("张三", "002");
        Student student3 = new Student("张三", "003");
        Student student4 = new Student("张三", "004");
        Student student5 = new Student("张三", "005");

        StudentAggregate studentAggregate = new StudentAggregateImpl();
        studentAggregate.addStudent(student1);
        studentAggregate.addStudent(student2);
        studentAggregate.addStudent(student3);
        studentAggregate.addStudent(student4);
        studentAggregate.addStudent(student5);

        StudentIterator iterator = studentAggregate.getStudentIterator();

        System.out.println(iterator.hasNext());
        while (iterator.hasNext()) {

            System.out.println(iterator.next());
        }

    }
}
